function createid() {
    return Math.random().toString().substr(3, 6)
}
function temp(num,data={}){
    return {
        id: Number(num.id) || Number(createid()),
        name:num.name?num.name:(data.name?data.name:''),
        age: num.age?num.age:(data.age?data.age:''),
        avatar: num.avatar?num.avatar:(data.avatar?data.avatar:''),
        city:num.city?num.city:(data.city?data.city:''),
        email:num.email?num.email:(data.email?data.email:'')
    }
}
function temp1(data, target = {}) {
    let obj = {}
    let target_data = data.filter(r => r.id == target.id)
    for (let key in data[0]) {
        if (!target.id) {
            obj.id = createid()
            obj[key] = target[key] ? target[key] : ''
        } else {
            obj[key] = target[key] ? target[key] : (target_data[0][key] ? target_data[0][key] : '')
        }
    }
    return obj
}
module.exports=temp
module.exports=temp1